<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "goods".
 *
 * @property int $id
 * @property string $name
 * @property string $price
 * @property int $num
 * @property int $ktime
 * @property int $endtime
 * @property string $img
 */
class Goods extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'goods';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['name'], 'required'],
            [['price'], 'number'],
            [['num', 'ktime', 'endtime'], 'integer'],
            [['name', 'img'], 'string', 'max' => 50],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'name' => 'Name',
            'price' => 'Price',
            'num' => 'Num',
            'ktime' => 'Ktime',
            'endtime' => 'Endtime',
            'img' => 'Img',
        ];
    }

    //查询商品表数据
    public function getAll()
    {
        return Goods::find()->asArray()->all();
    }
}
